package web.Servlet.solr;

import domain.student;
import javafx.scene.control.Alert;
import service.Serviceimpl.SudentServiceImpl;
import service.studentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/*登录的servlet*/
@WebServlet(name = "solrTestServlet" ,urlPatterns = "/ywj")
public class solrTestServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        studentService studentService = new SudentServiceImpl();
        try {
            student login = studentService.login(new student(req.getParameter("name"), req.getParameter("password")));
            req.setAttribute("student",login);
            System.out.println("我尽力了！");
            req.getRequestDispatcher("5_19/admin.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
